package com.example.administrator.x2picturetransliteration.Home.Dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;

import com.example.administrator.x2picturetransliteration.R;
import com.umeng.socialize.bean.SHARE_MEDIA;

/**
 * 分享
 * Created by Administrator on 2019/8/20.
 */

public class ShareDialog extends Dialog{

    private hd mhd;

    private boolean judge = false;

    public ShareDialog(@NonNull Context context,hd mhd) {
        super(context, R.style.HomeDialog);

        this.mhd = mhd;
    }

    public ShareDialog(@NonNull Context context,boolean judge,hd mhd) {
        super(context, R.style.HomeDialog);

        this.judge = judge;

        this.mhd = mhd;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home_dialog_share);

        if (judge){

            findViewById(R.id.kjView).setVisibility(View.GONE);
            findViewById(R.id.puqView).setVisibility(View.GONE);
        }

        findViewById(R.id.endView).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                ShareDialog.this.dismiss();
            }
        });

        /** QQ */
        findViewById(R.id.qqView).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                mhd.hdff(SHARE_MEDIA.QQ,"1");
            }
        });

        /** QQ空间 */
        findViewById(R.id.kjView).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                mhd.hdff(SHARE_MEDIA.QZONE,"1");
            }
        });

        /** 微信 */
        findViewById(R.id.wxView).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                mhd.hdff(SHARE_MEDIA.WEIXIN,"1");
            }
        });

        /** 朋友圈 */
        findViewById(R.id.puqView).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                mhd.hdff(SHARE_MEDIA.WEIXIN_CIRCLE,"1");
            }
        });

    }

    @Override
    public void show() {
        super.show();
        /**
         * 设置宽度全屏，要设置在show的后面
         */
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.gravity= Gravity.BOTTOM;
        layoutParams.width= WindowManager.LayoutParams.MATCH_PARENT;
        layoutParams.height= WindowManager.LayoutParams.WRAP_CONTENT;

        getWindow().getDecorView().setPadding(0, 0, 0, 0);
        getWindow().setAttributes(layoutParams);

    }

    public interface hd{

        void hdff(SHARE_MEDIA type,String word);
    }
}
